package com.nlx.notes.module.core.handler;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

public class PhoneMaskSerializer extends JsonSerializer<String> {
    @Override
    public void serialize(String phone, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        if (phone != null ) {
            phone = phone.substring(0, 3) + "****" + phone.substring(7);
        }
        jsonGenerator.writeString(phone);
    }
}
